<!--
 * @Author: your name
 * @Date: 2020-11-12 14:07:45
 * @LastEditTime: 2020-11-18 14:20:47
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \vue-admin-beautiful-pro-template\src\views\opertation\index.vue
-->
<template>
  <div class="operation-container">
    <HHsearch
      ref="search"
      :search-options="searchOptions"
      @search="search"
      @reset="reset"
    ></HHsearch>
    <HHtable
      ref="table"
      :border="true"
      :height="400"
      :total="total"
      :table-data="tableData"
      :table-column="tableColumn"
      @page-click="pageClick"
    ></HHtable>
  </div>
</template>

<script>
  import HHsearch from '@/components/HH-search'
  import HHtable from '@/components/HH-table'
  import { operationRecord } from '@/api/common'
  export default {
    components: {
      HHsearch,
      HHtable,
    },
    data() {
      return {
        searchOptions: [
          {
            type: 'text',
            prop: 'oprationName',
            span: 6,
            label: '操作人名称：',
            placeholder: '选择或输入搜索',
          },
        ],
        tableColumn: [
          {
            prop: 'oprationname',
            label: '操作人名称',
          },
          {
            prop: 'username',
            label: '变更人名称',
          },
          {
            prop: 'remark',
            label: '变更说明',
          },
          {
            prop: 'createtime',
            label: '操作时间',
          },
        ],
        tableData: [],
        total: 0,
        params: {
          pageSize: 10,
          pageNumber: 1,
          oprationName: '',
        },
      }
    },
    mounted() {
      this.getOperationRecord()
    },
    methods: {
      getOperationRecord() {
        this.$refs.table.loading = true
        operationRecord(this.params).then((res) => {
          this.tableData = res.data.list
          this.total = res.data.total
          setTimeout(() => {
            this.$refs.table.loading = false
          }, 1000)
        })
      },
      search(res) {
        const arr = Object.keys(res)
        for (let i = 0; i < arr.length; i++) {
          this.params[arr[i]] = res[arr[i]]
        }
        this.getOperationRecord()
      },
      reset() {
        this.params = {
          pageSize: 10,
          pageNumber: 1,
          oprationName: '',
        }
        this.$refs.search.removeFilterArray()
        this.getOperationRecord()
      },
      pageClick(pager) {
        this.params.pageNumber = pager
        this.getOperationRecord()
      },
    },
  }
</script>

<style></style>
